//
//  AuthorInfoTableViewCell.m
//  Demo
//
//  Created by colawh on 2019/3/18.
//  Copyright © 2019年 colawhdfws. All rights reserved.
//

#import "AuthorInfoTableViewCell.h"
#import "DemoHelp.h"

@interface AuthorInfoTableViewCell ()



@property (nonatomic,strong) UILabel *infoLb;

@end

@implementation AuthorInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}
- (void)configUI{
    [self.bottomView addSubview:self.avator];
    [self.bottomView addSubview:self.infoLb];


}
- (void)configureCellWithStr:(NSString *)contentstr
{
    //    test
    _infoLb.text = contentstr;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.02 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.refreshBlock) {
            self.refreshBlock();
        }
    });
    
}
- (CGFloat)realHeight{
    UIView *superView = [UIView new];
    [super addSubview:self.contentView];
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    [self addSubview:superView];
    CGFloat heitght = [DemoHelp getViewHeight:superView]+50;
    
    return heitght;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat gap = 15;
    [_avator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(50, 50));
        make.left.mas_equalTo(gap);
        make.top.equalTo(self.bottomView).offset(gap);
        make.bottom.lessThanOrEqualTo(_avator.mas_bottom).offset(gap);
    }];
    [_infoLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_avator);
        make.left.equalTo(_avator.mas_right).offset(gap);
        make.right.equalTo(self.bottomView).offset(-gap);
        make.bottom.mas_equalTo(self.bottomView).offset(-gap);
    }];
 
}
- (UIImageView *)avator{
    if (!_avator) {
        _avator = [UIImageView new];
        _avator.clipsToBounds = YES;
        _avator.layer.cornerRadius = 25.0;
        _avator.backgroundColor = [UIColor greenColor];
    }
    return _avator;
}
- (UILabel *)infoLb{
    if (!_infoLb) {
        _infoLb = [DemoHelp getLbByFont:14];
        _infoLb.textColor = kUIColorFromRGBA(0x091522, 0.85);
        [DemoHelp setLbHuggingAndCompress:_infoLb];
        _infoLb.numberOfLines = 0;
    }
    return _infoLb;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
